import allure
from selenium.webdriver.common.by import By

from base.base import Base


class page_register(Base):
    #输入账号
    @allure.step('1.输入用户名')
    def __input_username(self,username):
        self.element_send_keys((By.CSS_SELECTOR,"#username"),username)
#输入图像验证码
    @allure.step('2.输入图像验证码')
    def __input_verify_code(self,code):
        self.element_send_keys((By.NAME,"verify_code"),code)

#输入设置密码
    @allure.step('3.输入设置密码')
    def __input_password(self,password):
        self.element_send_keys((By.CSS_SELECTOR,"#password"),password)

#输入确认密码
    @allure.step('4.输入确认密码')
    def __input_password2(self,password2):
        self.element_send_keys((By.CSS_SELECTOR,"#password2"),password2)
#输入推荐人手机号
    @allure.step('5.输入推荐人手机号')
    def __input_mobile(self,mobile):
        self.element_send_keys((By.NAME,"invite"),mobile)
#点击注册按钮
    @allure.step('6.点击注册按钮')
    def __click_register_button(self):
        self.element_click((By.CSS_SELECTOR,".regbtn.J_btn_agree"))
#获取错误文本信息
    def get_error_text(self):
        return self.get_text((By.CSS_SELECTOR,".layui-layer-content.layui-layer-padding"))

    def register(self,username,code,password,password2,mobile):
        self.__input_username(username)#输入账号
        self.__input_verify_code(code)#输入图像验证码
        self.__input_password(password)#输入设置密码
        self.__input_password2(password2)#输入确认密码
        self.__input_mobile(mobile)#输入推荐人手机号
        self.__click_register_button()#点击注册按钮